From 3bb420f22fc7acea5ad645a87c96d118b2b2a48b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 11 Feb 2015 09:21:04 -0800 Subject: [PATCH] Add more error reporting for failing to join paths Hopefully this will help diagnose #1083 --- src/cargo/util/errors.rs | 10 ++++++++++ src/cargo/util/paths.rs | 12 ++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/cargo/util/errors.rs b/src/cargo/util/errors.rs index 5b03a9668..a13e7410f 100644 --- a/src/cargo/util/errors.rs +++ b/src/cargo/util/errors.rs @@ -70,6 +70,16 @@ impl ChainError for Result { } } +impl ChainError for Box { + fn chain_error(self, callback: C) -> CargoResult + where E2: CargoError, C: FnOnce() -> E2 { + Err(Box::new(ChainedError { + error: callback(), + cause: self, + }) as Box) + } +} + impl ChainError for Option { fn chain_error(self, callback: C) -> CargoResult where E: CargoError, C: FnOnce() -> E { diff --git a/src/cargo/util/paths.rs b/src/cargo/util/paths.rs index 3284681c2..f02fefe10 100644 --- a/src/cargo/util/paths.rs +++ b/src/cargo/util/paths.rs @@ -4,7 +4,7 @@ use std::old_io; use std::old_path::BytesContainer; use std::os; -use util::{human, CargoResult}; +use util::{human, internal, CargoResult, ChainError}; pub fn realpath(original: &Path) -> old_io::IoResult { const MAX_LINKS_FOLLOWED: usize = 256; @@ -47,8 +47,12 @@ pub fn realpath(original: &Path) -> old_io::IoResult { #[allow(deprecated)] // need an OsStr-based Command first pub fn join_paths(paths: &[T], env: &str) -> CargoResult> { - os::join_paths(paths).map_err(|e| { - human(format!("failed to join search paths together: {}\n\ - Does ${} have an unterminated quote character?", e, env)) + os::join_paths(paths).or_else(|e| { + let paths = paths.iter().map(|p| Path::new(p)).collect::>(); + internal(format!("failed to join path array: {:?}", paths)).chain_error(|| { + human(format!("failed to join search paths together: {}\n\ + Does ${} have an unterminated quote character?", + e, env)) + }) }) } -- 2.30.2